<template>
    <view class="u-page" style="background-color: #ffffff;padding: 10px">
      <up-form>
      <up-form-item
          label="补充内容："
          labelWidth="auto" >
<!--        <up-textarea style="height: 300px"  v-model="bcnr"></up-textarea>-->
      </up-form-item>
        <textarea style="border: black 1px solid;border-radius:5px;height: 300px;width: 90%" v-model="bcnr" placeholder="请输入补充内容"/>
      </up-form>
      <view style="margin-top: 100px">
        <up-button type="primary" style="width: 70%" @click="savebc">保存</up-button>
      </view>
    </view>
</template>

<script setup>
import {onLoad} from "@dcloudio/uni-app";
import { ref } from 'vue';
import { addBCAPI } from '@/api/system/sysIndex.js'

const laborId = ref('')
const bcnr = ref('')
const bcForm = ref({
  experimentMainId:'',
  supplementaryContent:''
})
onLoad((options) => {
  laborId.value = options.laborId
});

function savebc(){
    if (!bcnr){
      uni.showToast({
        title:  '请填写内容！',
        icon: "none",
      });
      return
    }
  bcForm.value.experimentMainId = laborId.value
  bcForm.value.supplementaryContent = bcnr.value
  addBCAPI(bcForm.value)
      .then((response) => {
        uni.showToast({
          title: ' 补充成功！',
          mask: false,
          icon: "success",
        });
        uni.redirectTo({
          url: '/pages/laboratory/myLabor'
        });
      }).catch((err) => {
        uni.showToast({
          title:err.message,
          mask: false,
          icon: "none",
        });
  })
}

</script>

<style lang="scss" scoped>

</style>
